package com.sjh.lib_app.statusMananger.defWidget

import android.content.Context
import android.view.Gravity
import android.view.View
import android.widget.ImageView
import android.widget.LinearLayout
import com.bumptech.glide.Glide
import com.sjh.baseutils.dp
import com.sjh.lib_app.statusMananger.StatusManager
import com.sjh.lib_app.statusMananger.StatusView
import com.sjh.lib_app.R

/**
 * 正在加载中的状态
 * @author SunJH
 * @date 2020/10/08
 */
class GifLoadingStatusView : StatusView() {
    companion object {
        const val LOAD_STATUS_RELOAD = "LoadingStatusView"
    }

    override fun createView(context: Context, statusManager: StatusManager): View {
        val view = LinearLayout(context)
        view.gravity = Gravity.CENTER
        val imgLoading = ImageView(context)
        imgLoading.layoutParams = LinearLayout.LayoutParams(90.dp.toInt(), 30.dp.toInt())
        Glide.with(context).asGif().load(R.drawable.app_good_loading).into(imgLoading)
        view.addView(imgLoading)
        view.setOnClickListener { statusManager.setOnClickEvent(LOAD_STATUS_RELOAD) }
        return view
    }
}
